Choosing
Help from the Help Menu
Every
application should provide a Help menu to allow the user to open the help file
with either the keyboard or the mouse. The Help menu should contain at least
one Contents menu item that, when chosen, displays the Contents tab or the main
topic in the help file. To support the Help menu, the application s main window
procedure should check for the Contents menu item and call the WinHelp
case WM_COMMAND:
switch (wParam) {
case IDM_HELP_CONTENTS:
WinHelp(hwnd,
"myhelp.hlp", HELP_CONTENTS, 0L);
return 0L;
.
.
.
}
break;
You can add
other menu items to the Help menu for topics containing general information
about the application. For example, if your help file contains a topic that
describes how to use the keyboard, you can place a Keyboard menu item on the
Help menu. To support additional menu items, your application must specify
either the context string or the context identifier for the corresponding topic
when it calls the WinHelp
case IDM_HELP_KEYBOARD:
WinHelp(hwnd, "myhelp.hlp",
HELP_COMMAND,
(LPSTR)"JumpID(\"myhelp.hlp\",\"IDM_HELP_KEYBOARD\")");
return 0L;
A better way
to display a topic is to use a context identifier. To do this, the help file
must assign a unique number to the corresponding context string, in the [MAP]
section of the project file. For example, the following section assigns the
number 101 to the context string IDM_HELP_KEYBOARD:
[MAP]
IDM_HELP_KEYBOARD 101
An
application can display the Keyboard topic by specifying the context identifier
in the call to the WinHelp
#define IDM_HELP_KEYBOARD 101
WinHelp(hwnd, "myhelp.hlp", HELP_CONTEXT, (DWORD)IDM_HELP_KEYBOARD);
To make
maintenance of an application easier, most programmers place their defined
constants (such as IDM_HELP_KEYBOARD in the previous example) in a single
header file. As long as the names of the defined constants in the header file
are identical to the context strings in the help file, you can include the
header file in the [MAP] section to assign context identifiers, as shown in the
following example:
[MAP]
#include <myhelp.h>
If a help
file contains two or more Contents topics, the application can assign one as
the default by using the context identifier and the HELP_SETCONTENTS value in a
call to the WinHelp